<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="/svn/common.js"></script>
<!-- Include the Google Friend Connect javascript library. -->
<script type="text/javascript" src="http://www.google.com/friendconnect/script/friendconnect.js"></script>

<link rel="shortcut icon" href="/svn/favicon.ico"/>
<link rel="icon" href="/svn/favicon.ico" type="image/x-icon" />
<!-- above is common for all pages -->
<link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css" rel="stylesheet" />	
<!-- above is common for jquery ui pages -->
<script type="text/javascript">
google.load('gdata', '1'); 
google.setOnLoadCallback(toggleBtn);//do nothing. 
function toggleBtn() { 
  initCommonAPI();
  $.geekGaTrackPage("UA-10316080-2");
  if (google.accounts.user.checkLogin('http://docs.google.com/feeds/') == '') { 
    document.getElementById("dBtn").value = "Grant Docs Access"; 
    document.getElementById("dBtn").onclick = function () {grantDocAccess();}; 
  } else { 
    document.getElementById("dBtn").value = "Revoke Docs Access"; 
    document.getElementById("dBtn").onclick = function () {revokeDocAccess();}; 
  } 
  if (google.accounts.user.checkLogin('http:// spreadsheets.google.com/feeds/') == '') { 
    document.getElementById("sBtn").value = "Grant Spreadsheet Access"; 
    document.getElementById("sBtn").onclick = 
    function() {grantSpreadsheetAccess();}; 
  } else { 
    document.getElementById("sBtn").value = "Revoke Spreadsheet Access"; 
    document.getElementById("sBtn").onclick = function () {revokeSpreadsheetAccess();}; 
  } 
  checkStatus(); 
} 
function grantDocAccess() { 
  var token = google.accounts.user.login('http://docs.google.com/feeds/'); 
  toggleBtn(); 
} 
function revokeDocAccess() { 
  var status = google.accounts.user.logout(toggleBtn(), 'http://docs.google.com/feeds/'); 
} 
function grantSpreadsheetAccess() { 
  var token = google.accounts.user.login('http://spreadsheets.google.com/feeds/'); 
  toggleBtn(); 
} 
function revokeSpreadsheetAccess() { 
  var status = google.accounts.user.logout(toggleBtn(),'http://spreadsheets.google.com/feeds/'); 
} 
function checkStatus() { 
  document.getElementById("doc_token").innerHTML = 
    'http://docs.google.com/feeds/' + ": " + 
    google.accounts.user.checkLogin('http://docs.google.com/feeds/');
  document.getElementById("sp_token").innerHTML = 
    'http://spreadsheets.google.com/feeds/' + ": " + 
    google.accounts.user.checkLogin('http://spreadsheets.google.com/feeds/');
} 
</script> 
</head> 
<body> 
	<input id="dBtn" type="button" value="Grant Docs Access" 
	onclick="grantDocAccess()"/><br> 
	<input id="sBtn" type="button" value="Grant Spreadsheet Access" onclick="grantSpreadsheetAccess()"/><br> 
	<input type="button" value="Check token status" 
	onclick="checkStatus()"><br> 
	<div id="doc_token"></div><br> 
	<div id="sp_token"></div> 
</body> 
</html>
